import optionsx from '@/Echarts/双向bar'
import * as echarts from 'echarts'
let options = JSON.parse(JSON.stringify(optionsx))
// const { echarts } = window

export default (element, data) => {
  const old = echarts.getInstanceByDom(element)
  if (old) old.dispose()
  const chart = echarts.init(element, 'theme')
  // eslint-disable-next-line no-unused-vars
  const source = data.map((res) => {
    return {
      name: res.type,
      value: res.Number
    }
  })
  chart.setOption(options)
  return chart
}
